//
//  CheckingRecordView.m
//  YIJU2.0HD
//
//  Created by 张金国 on 16/5/17.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "CheckingRecordView.h"
#import "CheckingRecordCustomCellModel.h"
#import "Masonry.h"
#import "Macro.h"

@interface CheckingRecordView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong)UITableView   *tableView;

@property (nonatomic, strong) NSMutableArray *model;


@end

@implementation CheckingRecordView

#pragma mark - init
- (instancetype)init {
    if (self == [super init]) {
        
        CheckingRecordCustomCellModel *model = [[CheckingRecordCustomCellModel alloc]init];
        model.personName = [NSString stringWithFormat:@"登记人：%@",@"张金国"];
        model.time = 123234256;
        model.detailRecord = @"1232454678980-990-";
        model.detailReviewQuestion = @"1234352464536547456u567sgshhgfhfgdfgh";
        model.detailImpression = @"dffdadjfagvfdnv;agaoidgaowhoweirhoqiwehfowngenvv";
      
        [self.model addObject:model];
        
        CheckingRecordCustomCellModel *model2 = [[CheckingRecordCustomCellModel alloc]init];
        model2.personName = [NSString stringWithFormat:@"登记人：%@",@"张金国"];
        model2.time = 123234256;
        model2.detailRecord = @"1232454678980-990-";
        model2.detailReviewQuestion = @"1234352464536547456u567sgshhgfhfgdfgh";
        model2.detailImpression = @"dffdadjfagvfdnv;agaoidgaowhoweirhoqiwehfowngenvv";
        
        [self.model addObject:model2];
        
        [self setupConstraints];
    }
    return self;
}

#pragma mark -<UITableViewDelegate,UITableViewDataSource>
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.model.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    id<CustomCellModel> cellModel = [self.model objectAtIndex:indexPath.row];
    UITableViewCell *cell = [UITableViewCell tableView:tableView cellWithModel:cellModel];
    return cell;
}

#pragma mark - private
- (void)setupConstraints {
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(70);
        make.left.right.bottom.equalTo(self);
    }];
}

#pragma mark - getter
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tableView.rowHeight = UITableViewAutomaticDimension;
        _tableView.estimatedRowHeight = 100;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.sectionHeaderHeight = 3.0;
        _tableView.sectionFooterHeight = 3.0;
        _tableView.backgroundColor = kTableViewBackgroundColor;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self addSubview:_tableView];
    }
    return _tableView;
}

- (NSMutableArray *)model{
    if (_model == nil) {
        _model = [NSMutableArray array];
    }
    return _model;
}


@end
